package com.duobaoyu.dby.supply.biz.exception;

import com.duobaoyu.dby.channel.adapter.enums.biz.config.GlobalErrorCodeEnum;
import com.duobaoyu.dby.supply.core.common.exception.CustomException;
import com.duobaoyu.dby.supply.core.common.exception.IException;

/**
 * 业务异常
 *
 * @author fengshaoyu
 * @version 1.0.0
 * @date 2023/9/25 15:49
 */
public class SupplyChainBizException extends CustomException {

	public SupplyChainBizException(String errorMsg) {
		super(errorMsg);
	}

	private SupplyChainBizException(String errorMsg, Object data) {
		super(errorMsg, data);
	}

	public SupplyChainBizException(Integer code, String errorMsg) {
		super(code, errorMsg);
	}

	private SupplyChainBizException(Integer code, String errorMsg, Throwable errorCourse) {
		super(code, errorMsg, errorCourse);
	}

	private SupplyChainBizException(Integer code, String errorMsg, Object data) {
		super(code, errorMsg, data);
	}

	private SupplyChainBizException(Integer code, String errorMsg, Object data, Throwable errorCourse) {
		super(code, errorMsg, data, errorCourse);
	}

	public static void fail(String message) {
		throw new SupplyChainBizException(GlobalErrorCodeEnum.BUSINESS_EXCEPTION_CODE.code(), message);
	}

	public static void fail(int code, String message) {
		throw new SupplyChainBizException(code, message);
	}

	public static void fail(int code, String message, Object data) {
		throw new SupplyChainBizException(code, message, data);
	}

	public static void fail(IException exception) {
		throw new SupplyChainBizException(exception.code(), exception.message());
	}

	public static void fail(IException exception, Object data) {
		throw new SupplyChainBizException(exception.code(), exception.message(), data);
	}
}
